* Do File (Democracy of Dating)

cd "" // update this based on what computer you are on.

insheet using "democracy of dating raw data.csv", clear

*Drop the unwanted/uneccessary variables
drop startdate-userlanguage
drop q60-q120

***rename the variables/clean up the dataset
*age
gen age = .
replace age = (2018 - q2)

*gender
gen male = .
replace male = 1 if q3 == "Male"
replace male = 0 if q3 == "Female"

*education
gen educ = .
replace educ = 1 if q4 == "Did not graduate from high school"
replace educ = 2 if q4 == "High school graduate"
replace educ = 3 if q4 == "Some college, but no degree (yet)"
replace educ = 4 if q4 == "2-year college degree"
replace educ = 5 if q4 == "4-year college degree"
replace educ = 6 if q4 == "Postgraduate degree (MA, MBA, MD, JD, PhD, etc.)"

*marriage status
replace q6=trim(q6)
gen married=1 if q6=="Married"
replace married=0 if q6~="Married" & q6~=""

*race
gen white = .
replace white = 1 if q7 == "White"
replace white = 0 if q7 != "White" & q7 !=""

encode(q7), generate(race)

*dating preferences
sort q19
encode(q19), gen(preference)

*sexuality
sort q12
encode(q12), gen(sexuality)

gen straight = .
replace straight = 1 if q12 == "Heterosexual/straight"
replace straight = 0 if q12 != "Heterosexual/straight" & q12 != ""

*transgender
gen trans = .
replace trans = 1 if q13 == "Yes"
replace trans = 0 if q13 != "Yes" & q13 != ""

*religion
sort q14
encode(q14), gen(religion)

*religiosity
sort q57
gen religiosity = .
replace religiosity = 1 if q57 == "Not at all important"
replace religiosity = 2 if q57 == "Slightly important"
replace religiosity = 3 if q57 == "Moderately important"
replace religiosity = 4 if q57 == "Very important"
replace religiosity = 5 if q57 == "Extremely important"

*ideology
gen ideo5 = .
replace ideo5 = 1 if q15 == "Very conservative"
replace ideo5 = 2 if q15 == "Conservative"
replace ideo5 = 3 if q15 == "Moderate"
replace ideo5 = 4 if q15 == "Liberal"
replace ideo5 = 5 if q15 == "Very liberal"

*partyid
sort q20
tab q20
encode(q20), gen(partyid)

*fixing partyid
gen viewer_party = .
replace viewer_party = 0 if q20 == "Democrat"
replace viewer_party = 1 if q20 == "Independent"
replace viewer_party = 2 if q20 == "Republican"

gen democrat_respondent=1 if viewer_party==0
replace democrat_respondent=0 if viewer_party==1 |  viewer_party==2

*political interest
gen poli_interest = .
replace poli_interest = 1 if q16 == "Hardly at all"
replace poli_interest = 2 if q16 == "Only now and then"
replace poli_interest = 3 if q16 == "Some of the time"
replace poli_interest = 4 if q16 == "Most of the time"

*employment
encode(q11), gen(employment)

gen employed=1 if employment==8
replace employed=0 if employment~=8 & employment~=.


*income
tab q17
gen income = .
replace income = 1 if q17 == "Less than $10,000"
replace income = 2 if q17 == "$10,000 - $19,999"
replace income = 3 if q17 == "$20,000 - $29,999"
replace income = 4 if q17 == "$30,000 - $39,999"
replace income = 5 if q17 == "$40,000 - $49,999"
replace income = 6 if q17 == "$50,000 - $59,999"
replace income = 7 if q17 == "$60,000 - $69,999"
replace income = 8 if q17 == "$70,000 - $79,999"
replace income = 9 if q17 == "$80,000 - $89,999"
replace income = 10 if q17 == "$90,000 - $99,999"
replace income = 11 if q17 == "$100,000 - $119,999"
replace income = 12 if q17 == "$120,000 - $149,999"
replace income = 13 if q17 == "$150,000 - $199,999"
replace income = 14 if q17 == "$200,000 - $249,999"
replace income = 15 if q17 == "$250,000 - $349,999"
replace income = 16 if q17 == "$350,000 - $499,999"
replace income = 17 if q17 == "$500,000 or more"

**Create Treatment
gen treatment=0 if q40_1~=. | q23_1~=. // control: saw no partisan information (female first, male second)
replace treatment=1 if q46_1~=. | q34_1~=. // republican (female first, male second)
replace treatment=2 if q51_1~=. | q28_1~=. // democrat (female first, male second)


**Create same party variable (same party of profile as viewer)
gen same_party = .
replace same_party = 1 if partyid == 1 & treatment == 2
replace same_party = 1 if partyid == 2 & treatment == 1
replace same_party = 0 if partyid == 1 & treatment == 1
replace same_party = 0 if partyid == 2 & treatment == 2
replace same_party = 0 if partyid == 2 & treatment == 2


***********************************************************
***********************************************************
**Now, let's look at our main effect (ATTRACTIVENESS SCORE)
gen attractiveness_score=q40_1
replace attractiveness_score=q46_1 if attractiveness_score==.
replace attractiveness_score=q51_1 if attractiveness_score==.
replace attractiveness_score=q23_1 if attractiveness_score==.
replace attractiveness_score=q34_1 if attractiveness_score==.
replace attractiveness_score=q28_1 if attractiveness_score==.

regress attractiveness_score i.treatment
test 1.treatment=2.treatment

regress attractiveness_score i.treatment age male educ i.married i.race preference sexuality trans i.religion religiosity i.partyid poli_interest i.employment income 
outreg2 using c:\users\swktstud\reg1, replace word

tab q15
gen ideology=-2 if q15=="Very conservative"
replace ideology=-1 if q15=="Conservative"
replace ideology=0 if q15=="Moderate"
replace ideology=1 if q15=="Liberal"
replace ideology=2 if q15=="Very liberal"

gen party_forced=q20
replace party_forced="Democrat" if ideology==1 | ideology==2
replace party_forced="Republican" if ideology==-1 | ideology==-2

egen attractiveness_score_std=std(attractiveness_score), mean(0) std(1)

*BY PARTY
regress attractiveness_score i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
outreg2 using attract.doc
regress attractiveness_score i.treatment if q20=="Republican"
test 1.treatment=2.treatment
outreg2 using attract.doc, append
regress attractiveness_score i.treatment if q20=="Independent"
test 1.treatment=2.treatment
outreg2 using attract.doc, append

regress attractiveness_score_std i.same_party // this is the effect in the attractiveness effects meta analysis


	gen age_lesseq_35=1 if age<=35
	replace age_lesseq_35=0 if age>35 & age~=.
	regress attractiveness_score_std i.same_party if age_lesseq_35==1

	regress attractiveness_score_std i.same_party##i.age_lesseq_35 


*relative to a standard deviation
regress attractiveness_score_std i.treatment 

regress attractiveness_score_std i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress attractiveness_score_std i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress attractiveness_score_std i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to the base rate
regress attractiveness_score i.treatment if q20=="Democrat"
mat b =e(b)
scalar rep_score_dem=b[1,2]
sum attractiveness_score if treatment==0 
scalar base_rate=r(mean)
disp rep_score_dem/base_rate
	
regress attractiveness_score i.treatment if q20=="Republican"
mat b =e(b)
scalar dem_score_rep=b[1,3]
sum attractiveness_score if treatment==0 
scalar base_rate=r(mean)
disp dem_score_rep/base_rate

regress attractiveness_score i.treatment if q20=="Independent"


**************************************************************
**************************************************************
*******************Next Outcome Variable: RESPOND
*create the response variable
gen respond = q41
replace respond=q47 if respond==""
replace respond=q52 if respond==""
replace respond=q24 if respond==""
replace respond=q35 if respond==""
replace respond=q29 if respond==""

gen respond_message = .
replace respond_message = 1 if respond == "Definitely not"
replace respond_message = 2 if respond == "Probably not"
replace respond_message = 3 if respond == "Possibly"
replace respond_message = 4 if respond == "Probably"
replace respond_message = 5 if respond == "Very probably"
replace respond_message = 6 if respond == "Definitely"

regress respond_message i.treatment
test 1.treatment=2.treatment

egen respond_message_std=std(respond_message), mean(0) std(1)



*BY PARTY
regress respond_message i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
outreg2 using respond.doc
regress respond_message i.treatment if q20=="Republican"
test 1.treatment=2.treatment
outreg2 using respond.doc, append
regress respond_message i.treatment if q20=="Independent"
test 1.treatment=2.treatment
outreg2 using respond.doc, append

*relative to a standard deviation
regress respond_message i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress respond_message i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress respond_message i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to the base rate
regress respond_message i.treatment if q20=="Democrat"
mat b =e(b)
scalar rep_score_dem=b[1,2]
sum respond_message if treatment==0 
scalar base_rate=r(mean)
disp rep_score_dem/base_rate
	
regress respond_message i.treatment if q20=="Republican"
mat b =e(b)
scalar dem_score_rep=b[1,3]
sum respond_message if treatment==0 
scalar base_rate=r(mean)
disp dem_score_rep/base_rate

regress respond_message i.treatment if q20=="Independent"

regress respond_message_std same_party

**************************************************************
**************************************************************
*******************Next Outcome Variable: DATE
*create the would date variable

gen date = q42
replace date=q48 if date==""
replace date=q53 if date==""
replace date=q25 if date==""
replace date=q36 if date==""
replace date=q30 if date==""

gen go_date = .
replace go_date = 1 if date == "Definitely not"
replace go_date = 2 if date == "Probably not"
replace go_date = 3 if date == "Possibly"
replace go_date = 4 if date == "Probably"
replace go_date = 5 if date == "Very probably"
replace go_date = 6 if date == "Definitely"

regress go_date i.treatment
test 1.treatment=2.treatment

egen go_date_std=std(go_date), mean(0) std(1)



*BY PARTY
regress go_date i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
outreg2 using goonadate.doc
regress go_date i.treatment if q20=="Republican"
test 1.treatment=2.treatment
outreg2 using goonadate.doc, append
regress go_date i.treatment if q20=="Independent"
test 1.treatment=2.treatment
outreg2 using goonadate.doc, append

*relative to a standard deviation
regress go_date i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress go_date i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress go_date i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to the base rate
regress go_date i.treatment if q20=="Democrat"
mat b =e(b)
scalar rep_score_dem=b[1,2]
sum go_date if treatment==0 
scalar base_rate=r(mean)
disp rep_score_dem/base_rate
	
regress go_date i.treatment if q20=="Republican"
mat b =e(b)
scalar dem_score_rep=b[1,3]
sum go_date if treatment==0 
scalar base_rate=r(mean)
disp dem_score_rep/base_rate

regress go_date i.treatment if q20=="Independent"

regress go_date_std same_party 

**************************************************************
**************************************************************
*******************Next Outcome Variable: RELATIONSHIP
*create the relationship variable

gen relation = q43
replace relation=q49 if relation==""
replace relation=q54 if relation==""
replace relation=q26 if relation==""
replace relation=q37 if relation==""
replace relation=q31 if relation==""

gen relationship = .
replace relationship = 1 if relation == "Definitely not"
replace relationship = 2 if relation == "Probably not"
replace relationship = 3 if relation == "Possibly"
replace relationship = 4 if relation == "Probably"
replace relationship = 5 if relation == "Very probably"
replace relationship = 6 if relation == "Definitely"

regress relationship i.treatment
test 1.treatment=2.treatment

egen relationship_std=std(relationship), mean(0) std(1)

*BY PARTY
regress relationship i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
outreg2 using relationship.doc
regress relationship i.treatment if q20=="Republican"
test 1.treatment=2.treatment
outreg2 using relationship.doc, append
regress relationship i.treatment if q20=="Independent"
test 1.treatment=2.treatment
outreg2 using relationship.doc, append

*relative to a standard deviation
regress relationship i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress relationship i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress relationship i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to the base rate
regress relationship i.treatment if q20=="Democrat"
mat b =e(b)
scalar rep_score_dem=b[1,2]
sum relationship if treatment==0 
scalar base_rate=r(mean)
disp rep_score_dem/base_rate
	
regress relationship i.treatment if q20=="Republican"
mat b =e(b)
scalar dem_score_rep=b[1,3]
sum relationship if treatment==0 
scalar base_rate=r(mean)
disp dem_score_rep/base_rate

regress relationship i.treatment if q20=="Independent"

regress relationship_std same_party

**************************************************************
**************************************************************
*******************Next Outcome Variable: RECOMMEND
*create the set_up_friend variable

gen recommend = q121
replace recommend=q122 if recommend==""
replace recommend=q123 if recommend==""
replace recommend=q124 if recommend==""
replace recommend=q125 if recommend==""
replace recommend=q126 if recommend==""

gen set_up_friend = .
replace set_up_friend = 1 if recommend == "Definitely not"
replace set_up_friend = 2 if recommend == "Probably not"
replace set_up_friend = 3 if recommend == "Possibly"
replace set_up_friend = 4 if recommend == "Probably"
replace set_up_friend = 5 if recommend == "Very probably"
replace set_up_friend = 6 if recommend == "Definitely"

regress set_up_friend i.treatment
test 1.treatment=2.treatment

egen set_up_friend_std=std(set_up_friend), mean(0) std(1)

*BY PARTY
regress set_up_friend i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress set_up_friend i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress set_up_friend i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to a standard deviation
regress set_up_friend i.treatment if q20=="Democrat"
test 1.treatment=2.treatment
regress set_up_friend i.treatment if q20=="Republican"
test 1.treatment=2.treatment
regress set_up_friend i.treatment if q20=="Independent"
test 1.treatment=2.treatment

*relative to the base rate
regress set_up_friend i.treatment if q20=="Democrat"
mat b =e(b)
scalar rep_score_dem=b[1,2]
sum set_up_friend if treatment==0 
scalar base_rate=r(mean)
disp rep_score_dem/base_rate
	
regress set_up_friend i.treatment if q20=="Republican"
mat b =e(b)
scalar dem_score_rep=b[1,3]
sum set_up_friend if treatment==0 
scalar base_rate=r(mean)
disp dem_score_rep/base_rate

regress set_up_friend i.treatment if q20=="Independent"


******************************************************************************** Factor Weighted Scale


*No set up so we can be consistent about what is going into the scale (CCES doesn't have setup)
factor attractiveness_score respond_message go_date relationship
predict interact_scale

egen interact_scale_std=std(interact_scale), mean(0) std(1)

regress interact_scale_std same_party


********************************************************************************

*ssc install outreg2

regress attractiveness_score i.treatment age male educ i.married i.race preference sexuality trans i.religion religiosity i.partyid poli_interest i.employment income 
outreg2 using reg1.doc
regress respond_message i.treatment age male educ i.married i.race preference sexuality trans i.religion religiosity i.partyid poli_interest i.employment income 
outreg2 using reg1.doc, append
regress relationship i.treatment age male educ i.married i.race preference sexuality trans i.religion religiosity i.partyid poli_interest i.employment income 
outreg2 using reg1.doc, append
regress set_up_friend i.treatment age male educ i.married i.race preference sexuality trans i.religion religiosity i.partyid poli_interest i.employment income 
outreg2 using reg1.doc, append


***********************************************************
*************************Balance Tests/hets ********************
***********************************************************

sum age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income 

egen age_std=std(age), mean(0) std(1)

regress age_std same_party
regsave same_party using "balance_experiment_1.dta", detail(all) addlabel(outcome, age, experiment, 1) replace 


foreach var in  male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
egen `var'_std=std(`var'), mean(0) std(1)
regress `var'_std same_party
regsave same_party using "balance_experiment_1.dta", detail(all) addlabel(outcome, `var', experiment, 1) append 
}


foreach var in attractiveness_score respond_message go_date relationship set_up_friend ///
 age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
 
 gen `var'm=1 if `var'==.
 replace `var'm=0 if `var'~=.
 
 }
 
 foreach var in  attractiveness_score respond_message go_date relationship set_up_friend ///
 age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
tab `var'm
}

keep same_party age male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income attractiveness_scorem respond_messagem go_datem relationshipm set_up_friendm agem malem educm whitem democrat_respondentm ideo5m  employedm straightm transm religiositym poli_interestm incomem attractiveness_score respond_message go_date relationship set_up_friend married
gen experiment=1
save "pared_balance_experiment_1.dta", replace

**** SAVE OLD
use "balance_experiment_1.dta", clear

gen t=coef/stderr

saveold "balance_experiment_1.dta", version(12) replace




